package com.security.demo.dao;

import com.security.demo.entity.BtModule;
import com.security.demo.entity.BtUserPrivilege;
import org.apache.ibatis.annotations.*;

import java.util.List;
@Mapper
public interface BtUserPrivilegeDao {
    //插入用户id,模块，操作
    @Insert("insert into bt_user_privilege(USER_ID,MODULE_NAME,MODULE_OPERATION_NAME) values(#{userId},#{name},#{operationName})")
    public int insertBtUserModule(BtUserPrivilege btUserPrivilege);
    //删除指定用户对指定模块的指定操作
    @Delete("delete from bt_user_privilege where USER_ID = #{userId} and MODULE_NAME = #{name} and MODULE_OPERATION_NAME = #{operationName}")
    public int deleteBtUserModule(BtUserPrivilege btUserPrivilege);

    //根据用户id查询其某个模块拥有的操作
    @Select("select * from bt_user_privilege where USER_ID = #{userId} and MODULE_NAME = #{name}")
    @Results(value = {
            @Result(column = "AUTO_ID",property = "id"),
            @Result(column = "USER_ID",property = "userId"),
            @Result(column = "MODULE_NAME",property = "name"),
            @Result(column = "MODULE_OPERATION_NAME",property = "operationName")
    })
    @ResultType(value = BtUserPrivilege.class)
    public List<BtUserPrivilege> searchBtUserModule(BtUserPrivilege btModule);
}
